<template>
  <view>
    <form>
      <!-- <view class="cu-card margin radius">
        <view class="cu-form-group margin-top">
          <view class="title">项目编号</view>
          <view>{{ itemContent.projectno }}</view>
        </view>
        <view class="cu-form-group">
          <view class="title">项目名称</view>
          <view>{{ itemContent.projectname }}</view>
        </view>

      </view> -->
      <xmInfo
      :projectno="dataInfo.projectno"
      :projectname="dataInfo.projectname"
    ></xmInfo>

      <view class="cu-bar bg-white">
        <view class="action"><text class="cuIcon-favorfill text-xs text-red"></text
              >日志描述</view>
      </view>
      <view class="cu-form-group">
        <textarea
          maxlength="-1"
          :disabled="modalName != null"
          @input="textareaAInput"
          placeholder="请输入日志描述"
        ></textarea>
      </view>
      <view class="cu-form-group">
        <view class="title">日志类型</view>
        <view
          ><js-select
            v-model="model.logtype"
            dict-type="zf_proj_log_type"
            disabled
            inputAlign="right"
          ></js-select
        ></view>
      </view>
      <view style="height: 80px" v-if="showButton"></view>
      <view class="btn-group cu-bar foot" v-if="showButton">
        <button class="cu-btn bg-green shadow-blur" @click="confirm">
          提交
        </button>
      </view>
    </form>
  </view>
</template>
<script>
import xmInfo from "@/pages/zfgs/index/componetns/xmInfo.vue";
import {hasPermission} from '@/common/fire.js'
export default {
  components:{
        xmInfo
  },
  data() {
    return {
      date: "2024-03-12",
      modalName: null,
      imgList: [],
      modalNameDetail: null,
      showAddDetail: false,
      uploadOptions: {},
      content: "",
      model: {
        logtype: "2",
      },
      dataInfo: {},
      showButton: true,
      // flag:hasPermission('proj:log:pmPjournal:edit'),
      isSubmitting: false,
    };
  },
  onLoad(e) {
    this.dataInfo = JSON.parse(e.itemContent);
    console.log(this.dataInfo,'itemContent===');
  },
  methods: {
    textareaAInput(e) {
      this.content = e.detail.value;
    },

    confirm() {
      if (!this.content) {
        this.$u.toast("日志描述必填");
        return;
      }
      if (this.isSubmitting) {
        return;
      } else {
        this.isSubmitting = true;
        try {
          this.$u.api.zfgs
        .enexPmPjournalSave({
          content: this.content,
          logtype: this.model.logtype,
          projectname: this.dataInfo.projectname,
          projectno: this.dataInfo.projectno,
        })
        .then((res) => {
          if (res.result == "true") {
            this.$u.toast(res.message);
            setTimeout(() => {
              this.$u.route({
                type: "back",
              });
            }, 1500);
          } else {
            this.$u.toast(res.message);
          }
        });
        } catch (error) {
          this.$u.toast(error.message);
        } finally {
          this.isSubmitting = false;
        }
      }

    },
    imgListChange(e) {
      this.dataInfo.dImageList = e;
    },
  },
};
</script>
<style lang="scss" scoped>
.action {
  color: #303133;
}
.cu-form-group {
  flex-wrap: wrap;
}
.text-sl {
  font-size: 22px !important;
}
.cu-bar {
  min-height: 80px;
}
.cu-btn {
  font-size: 16px;
  height: 40px;
}
.foot {
  z-index: 997;
  background: #fff;
}
.text-xs {
  font-size: 18rpx !important;
}
</style>